<template>
	<view>
		<view class="summit">
			<view class="possible" v-if="userInfo.qrcode">
				<image :src="userInfo.qrcode"  mode="scaleToFill"></image>
			</view>
			<view class="Subbelong">
				<!-- #ifdef H5 -->
				<view class="envelope" >
					h5长按图片保存到相册
				</view>
				<!-- #endif -->
				<!-- #ifdef  MP-WEIXIN -->
				<view class="Avatar" v-if="userInfo.qrcode" >
					<u-button  text="点击保存" shape="circle" color="#ff6600" @click="handleBaocun(userInfo.qrcode)"></u-button>
				</view>
				<!-- #endif -->
			</view>
		</view>
		
		<view>
			<u-empty v-if="userInfo.qrcode == ''" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png">
			</u-empty>
		</view>
		
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,mapMutations
	} from "vuex"
	export default {
		data() {
			return {
				
			};
		},
		computed: {
			...mapState('user', ['userInfo', 'webSocket'])
		},
		onShow() {
			if (this.userInfo != null && this.userInfo != 'null') {
				this.getUserInfo()
			}
		},
		methods: {
			...mapActions('user', ['getUserInfo', 'remove']),
			...mapMutations('user', ['setWebSocket']),
			list(items) {
			                uni.previewImage({
			                    urls: [items]
			                })
			            },
				handleBaocun(code) {
								var that = this
								console.log( code)
								uni.getImageInfo({
									src: code,
									success: function(image) {
										console.log(image)
										wx.saveImageToPhotosAlbum({
											filePath: image.path,
											success: function() {
												uni.showModal({
													title: '保存成功',
													content: '图片已成功保存到相册',
													showCancel: false
												});
											},
											complete(res) {
												console.log(res);
											}
										});
									}
								})
							}
		}
	}
</script>

<style lang="scss">
.summit{
	text-align: center;
    padding: 100rpx;
	.possible{
		
		image{
			width: 400rpx;
			height: 400rpx;
		}
	}
}
.Subbelong{
.envelope{
	margin-top: 10rpx;
	font-size: 28rpx;
	color: #998890;
}
.Avatar{
	margin: 30rpx;
	
 }
}

</style>
